<template>
  <div class="Test">
    <button @click="change">点击显示/隐藏msg</button>
    <transition name="hello" appear>
      <h2 v-show="isShow">{{ msg }}</h2>
    </transition>
  </div>
</template>

<script>
export default {
  name: "Test",
  data() {
    return {
      isShow: "true",
      msg: "你好啊",
    };
  },
  methods: {
    change() {
      this.isShow = !this.isShow;
    },
  },
  components: {},
};
</script>

<style scoped>
.Test {
  margin: 0 auto;
}
h2 {
  margin: 0 auto;
  width: 300px;
  background-color: orange;
}

.hello-enter-active {
  animation: move 1s;
}
.hello-leave-active {
  animation: move 1s reverse;
}

@keyframes move {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0px);
  }
}
</style>
